<?php
declare (strict_types = 1);

namespace app\admin\controller;

use think\Request;
use app\admin\service\ExpandCustomer as ExpandCustomerService;
use app\admin\validate\ExpandCustomer as ExpandCustomerValidate;

class ExpandCustomer
{
    /**
     * 显示资源列表
     *
     * @return \think\Response
     */
    public function index(Request $request,ExpandCustomerService $ExpandCustomerService,ExpandCustomerValidate $validate)
    {
        $checkData = $request->param();
        if (!$validate->scene('search')->check($checkData)) {
            return json(['code' => 1, 'message' => $validate->getError()]);
        }

        $param['country'] =  $request->param('country',null);
        $param['city'] =  $request->param('city',null);
        $param['keywords'] =  $request->param('keywords',null);
        $param['source'] =  $request->param('source',null);

        $param['start_time'] =  $request->param('start_time',null);
        $param['end_time'] =  $request->param('end_time',null);

        $intPage =  $request->param('pageIndex',1);
        $intPageSize =  $request->param('pageSize',50);
        $arrData = $ExpandCustomerService->index($param,(int)$intPage,(int)$intPageSize);
        return json($arrData);
    }

    /**
     * 显示创建资源表单页.
     *
     * @return \think\Response
     */
    public function create()
    {
        //
    }

    /**
     * 保存新建的资源
     *
     * @param  \think\Request  $request
     * @return \think\Response
     */
    public function save(Request $request)
    {
        //
    }

    /**
     * 显示指定的资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function read(Request $request,ExpandCustomerService $ExpandCustomerService,ExpandCustomerValidate $validate)
    {
        $checkData = $request->param();
        if (!$validate->scene('show')->check($checkData)) {
            return json(['code' => 1, 'message' => $validate->getError()]);
        }
        $param['id'] = $request->param('id',null);
        $arrData = $ExpandCustomerService->read($param);
        return json($arrData);
    }

    /**
     * 显示编辑资源表单页.
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function edit($id)
    {
        //
    }

    /**
     * 保存更新的资源
     *
     * @param  \think\Request  $request
     * @param  int  $id
     * @return \think\Response
     */
    public function update(Request $request, $id)
    {
        //
    }

    /**
     * 删除指定资源
     *
     * @param  int  $id
     * @return \think\Response
     */
    public function delete($id)
    {
        //
    }
}
